<template>
  <div class="xzztl">
    <div class="select-module">
      <el-card>
        <i class="el-icon-search" style="font-size: 30px; font-weight: bold; color: #409eff; margin: 0 20px 0 0; position: relative; top: 5px;"></i>
        <div class="select-item">
          <span>协作组:</span>
          <el-select v-model="value1" placeholder="请选择">
            <el-option
              v-for="item in optionsValue1"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </div>
      </el-card>
    </div>
    <el-card>
      <!--筛选条件-->
      <div class="but-group-module">
        <el-button type="primary" @click="goTalk">进入讨论</el-button>
        <el-button type="primary" @click="clearParams">清除条件</el-button>
      </div>
      <div class="table-module">
        <el-table
          :data="tableData"
          border
          style="width: 100%">
          <el-table-column
            type="selection"
            width="55">
          </el-table-column>
          <el-table-column
            prop="CourseNumber"
            label="话题"
            width="100">
          </el-table-column>
          <el-table-column
            prop="CourseName"
            label="讨论"
            width="100">
          </el-table-column>
        </el-table>
      </div>
    </el-card>
    <div class="look-dialog">
      <el-dialog title="提示" :visible.sync="dialogPlanVisible" width="60%" custom-class="add-course-dialog">
        <div>
          <el-input v-model="titleValue" placeholder="请输入标题"></el-input>
          <div style="margin-top: 20px;">
            <el-input
              type="textarea"
              autosize
              placeholder="请输入内容"
              v-model="textareaValue">
            </el-input>
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="dialogPlanVisible = false">发表</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<style lang="scss" scoped>
  .xzztl {
    .select-module {
      .select-item {
        display: inline-block;
        margin-right: 30px;
        .el-select, .el-input {
          width: 150px;
        }
      }
    }
    .but-group-module {
      margin-bottom: 10px;
    }
    .table-module {
      text-align: center;
      /*padding: 10px;*/
      border: 1px solid #ccc;
    }
    .add-course-dialog {
      .content {
        .el-input {
          width: 200px;
          display: inline-block;
        }
        .el-select {
          width: 200px;
        }
        .el-textarea {
          max-width: 650px;
        }
        .item {
          margin-bottom: 10px;
          span {
            display: inline-block;
            width: 100px;
          }
        }
      }
      .el-dialog__body {
        padding: 15px 20px;
      }
    }
    .red-tips {
      color: #f33;
    }
  }
</style>

<script>
  import {getToken} from "../../utils/auth";

  export default {
    data() {
      return {
        titleValue: '',
        textareaValue: '',
        value1: '',
        value4: '',
        optionsValue1: [
          {
            value: '第一学期',
            label: '第一学期'
          },
          {
            value: '第二学期',
            label: '第二学期'
          },
        ],
        tableData: [],
        currentPageValue: 1, // 当前第几页
        pageNum: 10, // 每页数量
        totalData: '',
        dialogPlanVisible: false,
        dialogAddVisible: false,
        // 弹框里的值
      }
    },
    methods: {
      handleClick(params) {
        this.dialogPlanVisible = true
      },
      findQuery() {

      },
      clearParams() {},
      clearParams() {
        this.value1 = ''
      },
      async loadTableData() {
        let params = {
          token: getToken(),
          index: this.currentPageValue,
          pagemax: this.pageNum,
          category: this.value1,
          name: this.value4,
        }
        let res = await this.axios.get('v1/jxkc/getdata', {params: params})
        // console.log('哈哈')
        // console.log(res)
        let resData = res.data
        this.tableData = resData.data
        this.totalData = resData.count
        // console.log(this.tableData)
      },
      async saveApplyData() {
        this.dialogAddVisible = false
        let params = {
          token: getToken(),
          electiveCategory: this.value1,
          CourseCategory: this.value1,
          CourseId: this.value1,
          CourseName: this.value1,
          CourseEnName: this.value1,
          CourseAlias: this.value1,
          CourseCost: this.value1,
          OpeningInstitution: this.value1,
          OpeningCoefficient: this.value1,
          ExaminationForm: this.value1,
          TeachingMethods: this.value1,
          TotalHours: this.value1,
          TheoreticalHours: this.value1,
          PracticeHours: this.value1,
          OtherHours: this.value1,
          Bibliography: this.value1,
          Credit: this.value1,
          CourseIntroduction: this.value1,
          CourseNumber: this.value1,
          NoCourseNumber: this.value1,
        }
        let res = await this.axios.post('v1/jxkc/add_action', params)
        console.log('申请保存')
        console.log(res)
        if (res.data.code === 200) {
          this.$message({
            message: '保存成功',
            type: 'success'
          });
        }
      },
      goTalk() {
        this.dialogPlanVisible = true
      }
    },
    created() {
      this.loadTableData()
    }
  }
</script>
